package com.shawn.baseappbygroovydsl.ui.views

import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.View
import android.widget.TextView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import com.shawn.baseappbygroovydsl.R
import com.shawn.baseappbygroovydsl.databinding.FragmentIdeaBinding
import com.shawn.baseappbygroovydsl.ui.base.FragmentBase
import com.shawn.baseappbygroovydsl.utils.ExtensionCommon.dp
import com.shawn.baseappbygroovydsl.utils.UtilHundredContribute

class IdeaFragment : FragmentBase<FragmentIdeaBinding>(R.layout.fragment_idea) {
    override fun statusBar() {

    }

    override fun onKeyCodeBack(): Boolean {
        return false
    }

    override fun lazyLoad() {
        initView()
    }

    override fun initClick() {

    }

    private fun initView() {
        redChat()
    }

    private fun redChat() {
        mBind.btnChat.setOnClickListener {
            showFullScreenFrag(FragChat.newInstance(),R.anim.anim_drama_show)
        }
    }


    override fun getData() {

    }

    private fun loadUserIcon(view:View) {
        val tv = view as TextView
        tv.compoundDrawablePadding = 0.0f.dp.toInt()
        val size = 15f.dp.toInt()
        Glide.with(requireActivity()).load(UtilHundredContribute.curIcon()).override(size,size).transform(CircleCrop()).into(object :
            CustomTarget<Drawable>(){
            override fun onResourceReady(
                resource: Drawable,
                transition: Transition<in Drawable>?
            ) {
                tv.setCompoundDrawablesWithIntrinsicBounds(resource, null, null, null)
                tv.compoundDrawablePadding = 5.0f.dp.toInt()
            }

            override fun onLoadCleared(placeholder: Drawable?) {

            }
        })
    }

    override fun getBind(view: View): FragmentIdeaBinding {
        return FragmentIdeaBinding.bind(view)
    }

    companion object {
        const val type1 = "type"
        fun newInstance(): IdeaFragment {
            val args = Bundle()
            val fragment = IdeaFragment()
            fragment.arguments = args
            return fragment
        }
    }
}